package edu.neu.wsy.conf;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * <h1>文档服务配置类</h1>
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {

    /**
     * <h2>Swagger 实例 Bean 是一个Docket，所以通过配置 Docket 实例来配置 Swagger </h2>
     */
    @Bean
    public Docket docket(){
        return new Docket(DocumentationType.SWAGGER_2)
                //展示在Swagger页面上的自定义工程描述信息
                .apiInfo(apiInfo())
                //选择展示哪些接口
                .select()
                .apis(RequestHandlerSelectors.basePackage("edu.neu.swc"))
                .paths(PathSelectors.any())
                .build();
    }

    /**
     * <h2>配置Swagger的描述信息</h2>
     */
    public ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                .title("skynet-common-system")
                .description("WangY的微服务通用模板系统")
                .contact(new Contact(
                        "WangSongyao","","1178663139@qq.com"
                ))
                .version("1.0")
                .build();
    }
}
